<?php

class Template {

    public function __construct($fileName) {
        $this->templateData = file_get_contents($fileName);
    }

    public function bind ($key, $value) {
        $this->bindings[$key] = $value;
        return $this;
    }

    public function fetch () {
        $this->parsedTemplateData = $this->templateData;
        foreach ($this->bindings as $key => $value) {
            $this->parsedTemplateData = str_replace('{$'.$key.'}', $value, $this->parsedTemplateData);
        }
        return $this->parsedTemplateData;
    }

    private $templateData;
    private $parsedTemplateData;
    private $bindings = array();

}
